"use strict";
cc._RF.push(module, '8509dt9TtFFQIOmZqiwqC5G', 'ViewManager');
// Script/Manager/ViewManager.js

"use strict";

window.ViewMgr = {};

ViewMgr.showView = function (viewName) {
    console.log(viewName);

    ViewMgr.parent = cc.find("Canvas");

    var PrefabUrl = "Prefab/" + viewName + "Panel";
    //加载预制资源
    cc.loader.loadRes(PrefabUrl, function (errorMessage, loadedResource) {
        //检查资源加载
        if (errorMessage) {
            cc.log('载入预制资源失败, 原因:' + errorMessage);return;
        }
        if (!(loadedResource instanceof cc.Prefab)) {
            cc.log('你载入的不是预制资源!');return;
        }
        //开始实例化预制资源
        var panel = cc.instantiate(loadedResource);
        //将预制资源添加到父节点
        ViewMgr.parent.addChild(panel);

        console.log(viewName);
        var panelJs = require(viewName + "Panel");
        var panelObj = new panelJs();
        panelObj.viewName = viewName;
        panelObj.panel = panel;
        panelObj.awake();
    });
};

ViewMgr.hideView = function (viewName) {
    console.log(viewName);
};

module.exports = ViewMgr;

cc._RF.pop();